<template>
    <div>
        <form @submit="saveAddress">

            <div class="weui-cells weui-cells_after-title">

                <div class="weui-cell weui-cell_input">

                    <div class="weui-cell__hd">

                        <div class="weui-label">收货人</div>

                    </div>

                    <div class="weui-cell__bd">
                        <input class="weui-input" name="consignee" placeholder="请输入收货人真实姓名" />
                    </div>
                </div>

                <div class="weui-cell weui-cell_input">

                    <div class="weui-cell__hd">

                        <div class="weui-label">手机号</div>

                    </div>

                    <div class="weui-cell__bd">

                        <input class="weui-input" name="mobile" placeholder="请输入收货人手机号" />

                    </div>

                </div>

            </div>

            <div class="weui-cells__title"></div>

            <div class="weui-cells weui-cells_after-title">

                <div class="weui-cell weui-cell_input">

                    <div class="weui-cell__hd">

                        <div class="weui-label">详细地址</div>

                    </div>

                    <div class="weui-cell__bd">

                        <input class="weui-input" name="address" placeholder="请输入收货人详细地址">

                    </div>

                </div>

            </div>

            <button style='background: #ff8d1a;' class="weui-btn" type="primary" form-type="submit">保存</button>

        </form>
    </div>
</template>

<script>
import { formatTime } from "@/utils/index";
import card from "@/components/card";
var addressList = null;
export default {
    components: {
        card
    },

    data() {
        return {
            transportIndex: 0
        };
    },

    created() {
        const logs = wx.getStorageSync("logs") || [];
        this.logs = logs.map(log => formatTime(new Date(log)));
    },
    methods: {
        bindTransportDayChange: function(e) {
            console.log(
                "picker country 发生选择改变，携带值为",
                e.detail.value
            );

            that.transportIndex = e.detail.value;
        },

        bindCountyNameChange: function(e) {
            var that = this;

            console.log("picker county 发生选择改变，携带值为", e.detail.value);

            that.countyIndex = e.detail.value;
        },

        saveAddress: function(e) {
            var consignee = e.mp.detail.value.consignee;

            var mobile = e.mp.detail.value.mobile;

            var transportDay = e.mp.detail.value.transportDay;

            var provinceName = e.mp.detail.value.provinceName;

            var cityName = e.mp.detail.value.cityName;

            var countyName = e.mp.detail.value.countyName;

            var address = e.mp.detail.value.address;

            var arr = wx.getStorageSync("addressList") || [];

            console.log("arr,{}", arr);

            addressList = {
                consignee: consignee,

                mobile: mobile,

                address: address,

                // transportDay: transportDay
            };

            arr.push(addressList);

            wx.setStorageSync("addressList", arr);

            wx.navigateBack({});
        }
    }
};
</script>

<style>
.weui-cells:before {
    top: 0;
    border-top: 1rpx solid white;
}

.weui-cell {
    line-height: 50px;
}

.weui-cells:after {
    bottom: 0;
    border-bottom: 1rpx solid white;
}

.weui-btn {
    width: 100%;
    position: absolute;
    bottom: 1px;
    font-size: 33rpx;
    border-radius: 0;
    height: 94rpx;
    line-height: 94rpx;
}

.button-hover {
}

.weui-label {
    font-size: 32rpx;
    margin-left: 30rpx;
}

.weui-input {
    width: 700rpx;
    height: 130rpx;
    border-bottom: 1px solid #eee;
    margin: 0 auto;
    font-size: 30rpx;
}
</style>
